package com.fjp.heartguard.ui.report.adapter

import android.content.Intent
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.fjp.heartguard.R
import com.fjp.heartguard.app.Constants
import com.fjp.heartguard.app.data.bean.OlderInfo
import com.fjp.heartguard.app.data.bean.ReportsItem
import com.fjp.heartguard.app.ext.setAdapterAnimation
import com.fjp.heartguard.app.util.SettingUtil
import com.fjp.heartguard.ui.question.RecordActivity
import com.fjp.heartguard.ui.report.SingleAllReportActivity


class OlderAdapter(data: ArrayList<OlderInfo>) : BaseQuickAdapter<OlderInfo, BaseViewHolder>(R.layout.item_older, data) {
    init {
        setAdapterAnimation(SettingUtil.getListMode())
    }

    override fun convert(holder: BaseViewHolder, item: OlderInfo) {
        holder.setText(R.id.nameTv, item.name)
        holder.setText(R.id.mobileTv, item.mobile)
        if (item.sex == "男") {
            holder.setBackgroundResource(R.id.avatarIv, R.drawable.avatarman)
        } else {
            holder.setBackgroundResource(R.id.avatarIv, R.drawable.avatar_woman)
        }
        holder.getView<TextView>(R.id.testHistoryTv).setOnClickListener {
            val intent = Intent(context,SingleAllReportActivity::class.java)
            intent.putExtra(Constants.Intent_OLDER_ID,item.id)
            context.startActivity(intent)
        }
        holder.getView<TextView>(R.id.reTestTv).setOnClickListener {
            val intent = Intent(context, RecordActivity::class.java)
            intent.putExtra(Constants.Intent_REPORT, item)
            context.startActivity(intent)
        }

    }

}


